package com.tamtamy.jttamobile.data;

import java.net.URLEncoder;
import java.util.Arrays;

public class Metadata {
	
	public String pageTitle;
	public String pageDescription;
	public String[] tags;
	
	public Metadata() {
		this.pageTitle = null;
		this.pageDescription = null;
		this.tags = null;
	}
	
	public Metadata(String pageTitle, String pageDescription, String[] tags) {
		this.pageTitle = pageTitle;
		this.pageDescription = pageDescription;
		this.tags = tags;
	}

	public String getPageTitle() {
		return pageTitle;
	}

	public void setPageTitle(String pageTitle) {
		this.pageTitle = pageTitle;
	}

	public String getPageDescription() {
		return pageDescription;
	}

	public void setPageDescription(String pageDescription) {
		this.pageDescription = pageDescription;
	}

	public String[] getTags() {
		return tags;
	}

	public void setTags(String[] tags) {
		this.tags = tags;
	}
	
	public static String encodeURL(String url) throws Exception {
		String httpEncoded=URLEncoder.encode("http://", "UTF-8");	
		if(url.startsWith("http://")){
		  url = url.replace("http://", httpEncoded);
		}else{
		  url = httpEncoded + url;
		}
		url = url.replace(".", ",");
		return url;
	}
	
	@Override
	public String toString() {
		return "Metadata [pageTitle=" + pageTitle + ", pageDescription="
				+ pageDescription + ", tags=" + Arrays.toString(tags) + "]";
	}

}
